<%@page import="com.oceansoft.core.dao.util.SQLUtil"%>
<%@page import="com.hui.platform.system.utility.StringUtil"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Map"%>
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<%
		int w = 230;
		if("1".equals("2"))
		{
			w = 120;
		}
		SQLUtil util = new SQLUtil();
		
		String deep = request.getParameter("deep");
		if(StringUtil.isNull(deep))
		{
			deep="1";
		}
		String code = request.getParameter("code");
		if(StringUtil.isNull(code))
		{
			code="";
		}
		else
		{
			if(!"1".equals(deep))
			{
				code = code.substring(0,Integer.parseInt(deep)*2-3);
			}
			else
			{
				code = "";
			}
		}
		String sql  = "select code,context name from view_dicbm t where 1=1 and zdmc='物品类型' ";
		if(StringUtil.isNotNull(code))
		{
			code = code+"__";
			for(int i=code.length();i<5;i++)
			{
				code += "0";
			}
			
			sql += " and code like '"+code+"' and code!='"+request.getParameter("code")+"'";
		}
		else
		{
			sql += " and code like '_0000' ";
		}
		System.out.println(sql);
		List list = util.list(sql);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
		<script type="text/javascript" src="<c:url value='/resource/js/jquery-1.7.2.min.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/resource/artdialog/artdialog.js?skin=${sys_theme}'/>"></script>
		<script type="text/javascript" src="<c:url value='/resource/artdialog/iframetools.js'/>"></script>
		<!-- 部门选择 -->
		<style type="text/css">
			#choose-a-police{margin:0px;border: 1px solid #C3C3C3;}
			#choose-a-police{overflow-x: hidden;overflow-y: auto;height: 400px;}
			#choose-a-police span{
				height: 18px;line-height: 18px;color:#005EAC;text-decoration: none;
				font-size:10pt;font-family: Tahoma, Verdana, STHeiTi, simsun, sans-serif;
				float: left;width:<%=w%>px;margin:4px 4px;cursor:pointer;padding-left:12px;
			}
			
			#choose-a-police span a{
				height: 18px;line-height: 18px;color:#005EAC;text-decoration: none;
				font-size:10pt;font-family: Tahoma, Verdana, STHeiTi, simsun, sans-serif;
				  margin:4px 4px;cursor:pointer;padding-left:24px;
			}
			#choose-a-police span a:hover{background-color:#005EAC;color:white;cursor:pointer;}
  		</style>
</head>
<body>
	
	<div id="choose-a-police">
	
	<span>
				<%
					if(Integer.parseInt(deep)>1)
					{
						%>
						<img alt="" src="<%=path%>/resource/images/top.gif" border="0" onclick="downSel('<%=code %>','<%=deep %>',-1)">
						<%
					}
				%>
	</span>
	<span  >&nbsp; </span>
	<span  >&nbsp; </span>
	<%
		for(int i =0;i<list.size();i++)
		{	
			Map m = (Map)list.get(i);
			String name = (String)m.get("NAME");
			String code_ = (String)m.get("CODE");
			//System.out.println(code_);
	%>
	
				<span  >
				<a  href="javascript:selOption('<%=code_ %>','<%=name %>')" >
				<%=name %>
				</a>
				
				<%
					if(Integer.parseInt(deep)>1)
					{
						%>
						<img alt="" src="<%=path%>/resource/images/top.gif" border="0" onclick="downSel('<%=code_ %>','<%=deep %>',-1)">
						<%
					}
				%>
				
				<%
					if(Integer.parseInt(deep)<3)
					{
						%>
						<img alt="" src="<%=path%>/resource/images/down.gif" border="0" onclick="downSel('<%=code_ %>','<%=deep %>',1)">
						<%
					}
				%>
				
				</span>
	<%
		}
	%>
	
	
	</div>
	<script type="text/javascript">
	 function selOption(code,name)
	 {
		 top.params[parent.params.length] = code;
		 top.params[parent.params.length] = name;
		 //
		 //alert(top.params)
		 art.dialog.tips('');
		 art.dialog.close();
	 }
	 
	 function downSel(code,deep,oper)
	 {
		 if(3==deep)
		 {
		 	code = code.substring(0,3)+"00";
		 }
		var url = "<%=path%>/common/wp_select.jsp";
		location.replace(url+"?code="+code+"&deep="+(parseInt(deep)+parseInt(oper)));
	
		 
	 }
	 
	 
	
	 
	 function disDownSel()
	 {
		 var a = document.getElementsByName("down_sel");
		 for(var i=0;i<a.length;i++)
		 {
		 	a[i].style.display = "none";
		 }
	 }
	 
	
	 </script>
 </body>
</html>